<!-- 头部组件 -->
<template>
  <div class="page-header">
    <!-- 判断是否需要返回 -->
    <div class="left-back" v-if="showBack" @click="$router.back()">
      <span class="iconfont">&#xe660;</span>返回
    </div>
    <span class="title-text">{{ title }}</span>
    <div class="right-menu">
      <!-- 判断是否已经登陆（从仓库中获取是否登陆） -->
      <span
        class="iconfont"
        v-if="!$store.state.isLogin"
        @click="$router.push({ name: 'user' })"
        >&#xe8a0;
      </span>
    </div>
  </div>
</template>

<script>
export default {
  name: "PageHeader",
  props: {
    title: {
      type: String,
      default: "软帝点餐",
    },
    showBack: {
      type: Boolean,
      default: false,
    },
  },
  setup() {},
};
</script>

<style lang="scss" scoped>
.page-header {
  @include flexbox(row, center, center);
  height: 45px;
  background-color: rgb(131, 245, 192);
  color: white;
  position: relative;
  .left-back {
    position: absolute;
    left: 10px;
  }
  .right-menu {
    @extend .left-back;
    left: unset;
    right: 10px;
  }
}
</style>
